package cn.elwy.rcp.ui.table.format;

import java.text.NumberFormat;

public class PercentColumnFormat extends DecimalColumnFormat {

  private static final long serialVersionUID = 1L;

  private static final String ZERO = "0.00%";
  private NumberFormat numberFormat;

  @Override
  protected String getDefaultValue() {
    return ZERO;
  }

  @Override
  public NumberFormat getFormat() {
    if (numberFormat == null) {
      NumberFormat format = (NumberFormat) super.getFormat();
      format.setMinimumFractionDigits(2);
      setFormat(format);
      numberFormat = format;
    }
    return numberFormat;
  }

}
